package org.javaboy.vhr.service;

import org.javaboy.vhr.mapper.EmployeetrainMapper;
import org.javaboy.vhr.model.Employeeec;
import org.javaboy.vhr.model.Employeetrain;
import org.javaboy.vhr.vo.EmpTrainVo;
import org.javaboy.vhr.vo.RespPageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;

@Service
public class EmployeetrainService {
    @Autowired
    private EmployeetrainMapper employeetrainMapper;

    public RespPageBean getEmployeeTrainByPage(Integer page, Integer size, Employeetrain employeetrain, Date[] beginDateScope) {
        if (page != null && size != null) {
            page = (page - 1) * size;
        }
        List<EmpTrainVo> data = employeetrainMapper.getEmployeeTrainByPage(page,size,employeetrain,beginDateScope);
        //List<EmpTrainVo> result = new ArrayList<>();

        Long total = employeetrainMapper.getTotal(employeetrain, beginDateScope);
        RespPageBean bean = new RespPageBean();
        bean.setData(data);
        bean.setTotal(total);
        return bean;
    }

    public Integer add(Employeetrain employeetrain){
        return employeetrainMapper.insertSelective(employeetrain);
    }

    public Integer update(Employeetrain employeetrain){
        return employeetrainMapper.updateByPrimaryKey(employeetrain);
    }

    public Integer delete(Integer id){
        return employeetrainMapper.deleteByPrimaryKey(id);
    }
}